<script>
init({
  title: 'Get Visible/Hidden Columns',
  desc: 'Get Visible/Hidden columns:<br>`$table.bootstrapTable(\'getVisibleColumns\')`<br>`$table.bootstrapTable(\'getHiddenColumns\')`.',
  links: ['bootstrap-table.min.css'],
  scripts: ['bootstrap-table.min.js']
})
</script>

<div id="toolbar">
<template>
    <button id="button" class="btn btn-secondary">getVisibleColumns</button>
    <button id="button2" class="btn btn-secondary">getHiddenColumns</button>
  </div>
  <table
    id="table"
    data-toggle="table"
    data-toolbar="#toolbar"
    data-height="460"
    data-show-columns="true"
    data-pagination="true"
    data-side-pagination="server"
    data-url="https://examples.wenzhixin.net.cn/examples/bootstrap_table/data"
>
    <thead>
      <tr>
        <th data-field="id" data-sortable="true">ID</th>
        <th data-field="name" data-sortable="true" data-visible="false">Item Name</th>
        <th data-field="price" data-sortable="true">Item Price</th>
      </tr>
    </thead>
  </table>
</template>

<script>
  const $table = $('#table')
  const $button = $('#button')
  const $button2 = $('#button2')

  function mounted () {
    $button.click(function () {
      alert(JSON.stringify($table.bootstrapTable('getVisibleColumns').map(function (it) {
        return it.field
      })))
    })

    $button2.click(function () {
      alert(JSON.stringify($table.bootstrapTable('getHiddenColumns').map(function (it) {
        return it.field
      })))
    })
  }
</script>
